<?php

/**
 * This file is part of the Framework03 PHP framework.
 * @author Walter Tamboer
 * @package Framework03
 */

/**
 * A view helper to create an url for the website.
 */
class FW_View_Helper_CreateUrl extends FW_View_Helper_Abstract
{
    /**
     * The entry point of this view helper.
     */
    public function createUrl($arguments = array())
    {
        $frontController = FW_Controller_Front::singleton();

        $url = rtrim($frontController->getBaseUrl(), '/');

		if (isset($arguments['controller']))
            $url .= '/' . $arguments['controller'];

		if (isset($arguments['action']))
			$url .= '/' . $arguments['action'];

		if (isset($arguments['parameters']))
		{
			foreach ($arguments['parameters'] as $value)
				$url .= '/' . $value;
		}
		
        return $url;
    }
}
